AutoCompleteCombo = function(inputTextName, inputHiddenName, listado, fieldWidth)   
{
	ac_inputTextName = inputTextName;
	ac_inputHiddenName = inputHiddenName;
	
    var ds = new Ext.data.Store({
       proxy: new Ext.data.HttpProxy({
            url: 'listados.list?listado='+listado
        }),
        reader: new Ext.data.XmlReader({
        	totalRecords: 'numRegistros',
			record: 'item',
			id: 'id'
		}, ['id', 'nombre'])    
	});
	
    // Custom rendering Template
    var resultTpl = new Ext.Template(
        '<div class="search-item">',
            '<h3>{nombre}</h3>',
        '</div>'
    );
	
	if (fieldWidth == undefined)
		fieldWidth = 300;
		
    var search = new Ext.form.ComboBox({
        store: ds,
        displayField:'nombre',
        valueField: 'id',
        typeAhead: false,
        loadingText: 'Buscando...',
        width: fieldWidth,
        pageSize:10,
        hideTrigger:true,
        tpl: resultTpl,
        queryParam : 'p1',
        minChars:2,
        onSelect: function(record){ // override default onSelect to do redirect
            inputHiddenIdItem.value=record.data.id;
            inputTextItem.value=record.data.nombre;
            inputTextItem.style.color=inputColor;
            this.collapse();
        },
        onEmptyResults: function(){
            inputTextItem.style.color='#FF0000';
            inputHiddenIdItem.value = -1;
        	this.collapse();
        }
    });
    var inputTextItem = document.getElementById(ac_inputTextName);
    var inputHiddenIdItem = document.getElementById(ac_inputHiddenName);
    if (inputTextItem != null)
    {
	    var inputColor = inputTextItem.style.color;
	   	search.applyTo(ac_inputTextName);
    }
}